package vn.com.vhc.babyui;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

public class DialogActivity extends Activity {
	String info = "";
	String tag =  "";
	TextView tvInfo;
	TextView tvNote;
	ImageView img;
	String strInfo;
	String strNote;
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_dialog_ok);
	}

	@Override
	protected void onStart() {
		super.onStart();
		Bundle bundle = getIntent().getExtras();

		info = bundle.getString("INFO");
		tag = bundle.getString("TAG");
		
		tvInfo = (TextView)findViewById(R.id.tvInfo);
		tvNote = (TextView)findViewById(R.id.lblNote);
		
		
		if (info.equalsIgnoreCase("SUCCESS")) {
			tvInfo.setText("Thông tin");
			if(tag.equalsIgnoreCase("REGISTER"))
			{
				tvNote.setText("Đăng kí thành công!");
			}
			if(tag.equalsIgnoreCase("LOGIN"))
			{
				tvNote.setText("Đăng nhập thành công!");
			}
		}
		else
		{
			img = (ImageView)findViewById(R.id.imgDialog);
			tvInfo.setText("Lỗi");
			img.setImageDrawable(getResources().getDrawable(R.drawable.messagebox_warning));
			if(tag.equalsIgnoreCase("REGISTER"))
			{
				
				tvNote.setText("Đăng kí thất bại!");
			}
			if(tag.equalsIgnoreCase("LOGIN"))
			{
				tvNote.setText("Đăng nhập thất bại!");
			}
		}
		
		
	}

	public void okDialog(View v) {
		if(tag.equalsIgnoreCase("REGISTER"))
		{
			Intent i = new Intent(getApplicationContext(), Login.class);
			startActivity(i);
		}
		if(tag.equalsIgnoreCase("LOGIN"))
		{
			Intent i = new Intent(getApplicationContext(), MainActivity.class);
			startActivity(i);
		}
		
		DialogActivity.this.finish();

	}

	public void cancelDialog(View v) {
		DialogActivity.this.finish();

	}

}
